let nums = [8,1,2,2,3]
var smallerNumbersThanCurrent = function(nums) {
    let data = new Array(nums.length).fill(0).map((item)=>new Array(2).fill(0))
    for(let i=0;i<nums.length;i++){
        data[i][1] = i
        data[i][0] = nums[i]
    }
    data.sort((a,b)=>a[0]-b[0])
    console.log(data);
    let chu = -1
    let ans = new Array(nums.length).fill(0)
    for(let i=0;i<ans.length;i++){
        if(chu==-1||data[i][0]>data[i-1][0]){
            chu = i
        }
        ans[data[i][1]] = chu
    }
    return ans
}
console.log(smallerNumbersThanCurrent(nums));
